# -*- coding:utf-8 -*-
"""
@file: mysql_demo.py 
@time: 2019/07/18
@author: 
descript:
"""
import pymysql

#在数据库中插入数据
def insertData(db,cursor):
	# 插入数据
	sql = """insert into student (id,name,age) values (1,'小明',18),(2,'小兰',18);"""
	try:
		# 执行sql语句
		cursor.execute(sql)
		# 提交到数据库执行
		db.commit()
		
		print("successfully insert data")
	except:
		# 发生错误时回滚
		db.rollback()


